import Mock from 'mockjs'

const List = []
const count = 200

for (let i = 0; i < count; i++) {
  List.push(Mock.mock({
    attend_id: i + 1,
    dept_name: Mock.Random.cname() + '部门',
    emp_code: Mock.Random.string(5),
    emp_name: Mock.Random.cname(),
    attend_date: Mock.Random.date(),
    week_day: Mock.Random.cword('一二三四五六日'),
    'week_day|1': ['一', '二', '三', '四', '五', '六', '日'],
    'confirm_status|1': ['正常', '异常'],
    holiday_type: '',
    time_type: '', // 时间段
    start_date: Mock.Random.date(),
    end_date: Mock.Random.date(),
    sign_up: Mock.Random.date(),
    sign_out: Mock.Random.date(),
    'sign_up_status|1': ['正常', '异常', '漏签'],
    'sign_out_status|1': ['正常', '异常', '漏签'],
    work_time: '',
    kq_memo: '',
    sign_up_info: '',
    sign_out_info: '',
    sign_up_addr: '',
    sign_out_addr: ''
  }))
}

export default [
  {
    url: '/infos',
    type: 'get',
    response: config => {
      const { page = 1, limit = 20, sort } = config.query

      let mockList = List

      if (sort === '-id') {
        mockList = mockList.reverse()
      }

      const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))

      return {
        code: 200,
        data: {
          total: mockList.length,
          items: pageList
        }
      }
    }
  }
]
